import { createBrowserRouter, Navigate } from "react-router-dom";
import App from "../App";
import Login from "../component/Login";
import Home from "../component/Home";
import Cate from "../component/Cate";
import Shopping from "../component/Shopping";
import My from "../component/My";
import Zong from "../component/Zong";
// let Authcomponent = props =>{
//     let Com = props.children.type
//     if (sessionStorage.getItem('token')) {
//         return <Com></Com>
//     }else{
//         return <Navigate to='/login'></Navigate>
//     }
// }
let router = createBrowserRouter([
	{
		path: "/",
		element: <App></App>,
		children: [
			{
				path: "/login",
				element: <Login></Login>,
			},
			{
				path: "/zong",
				element: <Zong></Zong>,
				children: [
					{
						path: "/zong/home",
						element: <Home></Home>,
					},
                    {
						path: "/zong/cate",
						element: <Cate></Cate>,
					},
                    {
						path: "/zong/shopping",
						element: <Shopping></Shopping>,
					},
                    {
						path: "/zong/my",
						element: <My></My>,
					},
					{
						path: "/zong",
						element: <Navigate to="/zong/home"></Navigate>, //重定向
					},

				],
			},
			{
				path: "/",
				element: <Navigate to="/login"></Navigate>, //重定向
			},
		],
	},
]);

export default router;
